/**
 *  *2010-7-24 下午04:05:28  add 
 */
package com.base.myproject.client.ui;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.core.XDOM;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.util.Point;
import com.extjs.gxt.ui.client.util.Size;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Html;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * 从服务器获得的html然后在本地显示，未完成获取html部分，未完成。。。。还有许多
 * @author Administrator 2010-7-24 javazgw@gmail.com
 */
public class MessageInfo extends ContentPanel {

	int width=200;
	int height = 100;
	public MessageInfo() {
		this.setScrollMode(Scroll.AUTO);
		this.setHeight(height);
		this.add(new Html("asjdlfjaslfj;als99999999999999999999999999jf;jas;fdj;jas"));
		this.setHeaderVisible(false);
	}

	public void showMessage() {
		RootPanel.get().add(this);
		el().makePositionable(true);
		Point p = position();
		
		el().setLeftTop(p.x, p.y);
		
		setSize(width, height);
	}
	 protected void onRender(Element target, int index) {
		 super.onRender(target, index);
	  sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS);
	 }
	protected Point position() {
		Size s = XDOM.getViewportSize();
		int left = s.width - width - 20 + XDOM.getBodyScrollLeft();
		int top = height;
		return new Point(left, top);
	}
	 public void onComponentEvent(ComponentEvent ce) {
		    super.onComponentEvent(ce);

		    switch (ce.getEventTypeInt()) {
		    case Event.ONCLICK:
		    	this.hide();
		        break;
		    
		    }
	 }
}
